package de.homelabs.bookmarkmanager.desktop.qt.menu;

import org.springframework.stereotype.Component;

import com.trolltech.qt.gui.QAction;
import com.trolltech.qt.gui.QMenu;
import com.trolltech.qt.gui.QWidget;

public class HContextMenu extends QMenu {

	//signals
	public Signal1<HAction> menuActionSignal = new Signal1<HAction>();
	
	public HContextMenu(){}
	
	public HContextMenu(QWidget parent){
		super(parent);
		HAction action = new HAction("add Bookmark");
		action.setActionKey("addBookmark");
		this.addAction(action);
		this.addAction("test2");
		this.triggered.connect(this, "triggered(QAction)");
	}
	
	/******************
	 * signal handler *
	 ******************/
	protected void triggered(QAction action){
		if (action instanceof HAction){
			System.out.println("triggered: "+action.text()+", key: "+((HAction) action).getActionKey());
			menuActionSignal.emit((HAction) action);
		}
	}
}
